import {info} from '@/api/auth/login'
import Cookies from 'js-cookie'
import axios from '#/utils/axios'
import router from '#/router';

export function loginSuccess(res) {
    //添加token Cookies
    axios.CancelToken.source().token = res.data;
    Cookies.set('token', res.data, {expires: 30})
    //初始化用户信息
    infoUser();

}

function infoUser() {
    info().then(({code, data}) => {
        if (code === 200) {
            sessionStorage.setItem('info', JSON.stringify(data))
            router.push({path: '/'});
        }
    });
}




